/* eslint-disable no-undef */
// eslint-disable-next-line no-unused-vars
function createImg(url, text, callback) {
  var img = document.createElement("img");
  img.src = url || "../../static/Img/tongji/1.png";
  img.onload = function () {
    var canvas = document.createElement("canvas"); //创建canvas标签
    var ctx = canvas.getContext("2d");
    var fontsize = 18;
    ctx.font = fontsize + "px Arial";
    var width = img.width;
    var height = img.height;
    canvas.width = width;
    canvas.height = height;
    ctx.drawImage(img, 0, 0, width, height);

    ctx.fillStyle = "#fff";
    ctx.font = fontsize + "px Calibri,sans-serif";
    ctx.shadowOffsetX = 1; //阴影往左边偏，横向位移量
    ctx.shadowOffsetY = 0; //阴影往左边偏，纵向位移量
    ctx.shadowColor = "#fff"; //阴影颜色
    ctx.shadowBlur = 1; //阴影的模糊范围
    // ctx.textAlign="center"; //文字居中

    var y = height / 2 + 4;
    var x = width / 2 - (text.length * 9) / 2;
    ctx.fillText(text, x, y);
    callback(canvas);
  };
}
